<?php if ( ! defined('WDK_PATH')) exit('No direct script access allowed');?>
<!--{**************************************************************************}-->
<style>
span.cmt	{color:#DC4616;font-size: 11px;font-weight: bold;cursor: pointer;}
.r_agree	{color:#DC4616;}
.r_opposite	{color:#3A99DC;}
</style>
<!--{**************************************************************************}-->
<table id="listTable" class="list">
	<caption>
		<div class="fl">
			총 <span id="total">0</span>개의 게시물이 등록되어있습니다.
		</div>
		<div class="fr">
			<form id="searchForm" onsubmit="return false;">
				<input type="hidden" name="bbs_seq" value="{bbs.bbs_seq}"/>
				<input type="hidden" name="bbs_id" value="{bbs.bbs_id}"/>
				<input type="hidden" name="page" value="{page}"/>
				<select name="sf">
					<option value="post_title"{? sf == 'post_title'} selected="selected"{/}>제목</option>
					<option value="post_content"{? sf == 'post_content'} selected="selected"{/}>내용</option>
				</select>
				<input type="text" name="sk" class="input" value="{sk}"/>
				<a href="javascript:;" class="btn">검색</a>
				<a id="btn_rss"><img src="/images/buttons/rss.gif"/></a>
			</form>
		</div>
	</caption>
	<colgroup>
		<col style="width:60px;"/>
		<!--{? bbs.bbs_category_flag == 'T'}-->
		<col style="width:120px;"/>
		<!--{/}-->
		<col style="width:*;"/>
		<col style="width:120px;"/>
		<col style="width:60px;"/>
		<col style="width:80px;"/>
		<!--{? bbs.bbs_recommend_flag == 'T'}-->
		<col style="width:40px;"/>
		<col style="width:40px;"/>
		<!--{/}-->
	</colgroup>
	<thead>
		<tr>
			<th>No</th>
			<!--{? bbs.bbs_category_flag == 'T'}-->
			<th id="post_category_col">카테고리</th>
			<!--{/}-->
			<th>제목</th>
			<th>작성자</th>
			<th>조회수</th>
			<th>등록일</th>
			<!--{? bbs.bbs_recommend_flag == 'T'}-->
			<th id="post_recommend_col">추천</th>
			<th>반대</th>
			<!--{/}-->
		</tr>
	</thead>
	<tbody data='{json}'></tbody>
	<tfoot>
		<tr>
			<td colspan="8">
				<div class="fl">
					<a id="btn_list" class="btn" href="javascript:;">목록</a>
					<!--{? bbs->isWritable() }-->
					<a id="btn_new" class="btn" href="javascript:;">등록</a>
					<!--{/}-->
				</div>
				<div id="pagebar" class="fr"></div>
			</td>
		</tr>
	</tfoot>
</table>
{# plugin listmanager #}
<!--{**************************************************************************}-->
<script>
(function($){
	var page = $('#searchForm>:hidden[name=page]').val();
	var fk_category_seq = Number($('#searchForm>:hidden[name=bbs_id]').val());
	$('#btn_list').click(function(){
		location.href = $PATH+'{bbs.bbs_id}';
	});

	$('#btn_new').click(function(){
		location.href = $PATH+'edit/{bbs.bbs_id}';
	});

	$('#btn_rss').click(function(){
		location.href = '/rss/{bbs.bbs_id}';
	});
	WdListManager.prototype.draw = function(json)
	{
		var comment = '';
		if(json.comment_num > 0)
		{
			comment = ' <span class="cmt">['+json.comment_num+']</span>';
		}
		var tag = [];
		tag.push('<td class="tc"><input type="hidden" value="'+json.seq+'"/>'+json.no+'</td>');
		if($('#post_category_col').length == 1)
		{
			tag.push('<td class="tc ">'+json.category_name+'</td>');			
		}
		tag.push('<td class="">&nbsp;&nbsp;<a class="view">'+json.title+'</a>'+comment+'</td>');
		tag.push('<td class="tc"><a class="userinfo" uli="'+json.user_login_id+'">'+json.user_nick+'</a></td>');
		tag.push('<td class="tc">'+json.hits+'</td>');
		tag.push('<td class="tc">'+json.insert_time+'</td>');
		if($('#post_recommend_col').length == 1)
		{
			tag.push('<td class="tc r_agree">'+json.agree+'</td>');
			tag.push('<td class="tc r_opposite">'+json.opposite+'</td>');			
		}
		return tag.join("");
	};
	WdListManager.prototype.draw_event = function()
	{
		var view_url = $PATH+'view/{bbs.bbs_id}/:post_seq:/'+this.page;
		view_url+= '/'+(this.params['category_seq']?this.params['category_seq']:'0'); 
		view_url+= '/'+(this.params['sf']?this.params['sf']:'0'); 
		view_url+= '/'+(this.params['sk']?this.params['sk']:'0'); 
		$(this.root+'>tbody>tr').map(function(){
			var self = $(this);
			self.find('a.view').click(function(){
				location.href = view_url.replace(':post_seq:', self.find(':hidden').val());
			});
			self.find('span.cmt').click(function(){
				popup($PATH+'comment_pop/{bbs.bbs_id}/'+self.find(':hidden').val(),840,630, 'commentpop');
			});
			self.find('a.userinfo').click(function(){
				userinfo($(this).attr('uli'));
			});
		});
	};
	$(document).ready(function(){
		wlm = new WdListManager($PATH);
		wlm.set_root('#listTable');
		wlm.set_totalbox('#listTable #total');
		wlm.set_pagebar('#listTable #pagebar');
		wlm.set_param('bbs_id', '{bbs.bbs_id}');
		wlm.set_page(page);
		wlm.preload();
	});
})(jQuery);
</script>
<!--{**************************************************************************}-->